package forJava;

public class PassByValue {

    public static void main(String[] args) {

        int number = 10;
        swapInteger(number);
        System.out.println("main -> " + number + "\n");

        User user = new User();
        user.setAge(10);
        user.setName("jack");
        changeUser(user);
        System.out.println(user + "\n");

        String string = "main";
        changeString(string);
        System.out.println(string + "\n");

    }

    static void swapInteger(int number) {

        number *= 10;
        System.out.println("swapInteger -> " + number);
    }

    static void changeUser(User user) {

        user.setAge(100);
        user.setName("hanj");
        System.out.println(user);
    }

    static void changeString(String string) {

        string = "changeString";
        System.out.println(string);
    }

}

class User {

    int age;
    String name;

    public void setAge(int age) {

        this.age = age;
    }

    public void setName(String name) {

        this.name = name;
    }

    @Override
    public String toString() {

        return "User{" +
                "age=" + age +
                ", name='" + name + '\'' +
                "} " + this.hashCode();
    }

}
